import java.util.Scanner;


//    public static void main(String[] args) {
//        int[] array = {0, 1, 2, 3};
//        try {
//            System.out.println(array[7]);
//        }catch (ArrayIndexOutOfBoundsException e){
//            e.printStackTrace();
//            System.out.println("抛出异常");
//        }finally {
//            System.out.println("finally 执行");
//        }
//        System.out.println(array[2]);

//        int[] array = {0, 1, 2, 3};
//        Scanner scanner = new Scanner(System.in);
//        int k = scanner.nextInt();
//        if (k > 3){
//            throw new RuntimeException("数组越界");
//        }
//        else {
//            System.out.println(array[k]);
//        }


          class userError extends RuntimeException {
            public userError (String message){
                super(message);
            }
        }
        class PasswordError extends  RuntimeException{
            public PasswordError (String message){
                super(message);
            }
        }
        public class Test {
        private static String name = "admin";
        private static String password = "123456";
        public static void login(String name, String password){
        if (!Test.name.equals(name)){
            throw new userError("用户名错误");
        }
        if (!Test.password.equals(password)){
            throw  new PasswordError("密码错误");
        }
        System.out.println("登录成功");
    }
        public static void main(String[] args) {
            try {
                login("admin", "123456");
            }catch (userError userError){
                userError.printStackTrace();
            }catch (PasswordError passwordError){
                passwordError.printStackTrace();
            }
    }
}
